<template>
  <div class="category-item">
    <div class="cover">
      <img :src="cover" v-if="cover" class="cover-img" />
      <img v-else src="../assets/pp.jpg" class="cover-img" />
    </div>
    <div class="name">
      <router-link :to="'/web-category/' + categoryId" class="a-link">{{ name }}</router-link>
    </div>
    <div class="blogCount">{{ blogCount }} 篇</div>
  </div>
</template>

<script setup>
const props = defineProps({
  cover: {
    type: String,
  },
  name: {
    type: String,
  },
  blogCount: {
    type: Number,
    default: 0,
  },
  categoryId: {
    type: Number,
  },
});
</script>

<style lang="scss">
.category-item {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  margin-bottom: 15px;
  transition: all 0.3s ease;

  &:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  }

  .cover {
    width: 50px;
    height: 50px;
    background: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 50%;
    margin-right: 15px;
    transition: all 0.3s ease;
  }

  .cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    transition: transform 0.3s ease;
  }

  .cover:hover .cover-img {
    transform: scale(1.05);
  }

  .name {
    flex: 1;
    font-size: 16px;
    font-weight: bold;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 10px;
    transition: color 0.3s ease;

    &:hover {
      color: #1890ff;
    }
  }

  .blogCount {
    font-size: 14px;
    color: #999;
    font-weight: 400;
  }
}
</style>
